import { instantiate as instantiate_fetch } from "./features/fetch-load";
import { instantiate as instantiate_depcache } from "./features/depcache";
import { SystemJSCore } from "./system-core";
import { get, set, entries, _delete, has } from "./features/registry";
import { BASE_URL } from "./common";

export class SystemJS extends SystemJSCore {
    constructor() {
        super();
    }
    async instantiate(url: string, parent?: string) {
        await instantiate_depcache.call(this, url);
        return instantiate_fetch.call(this, url, parent);
    }
    fetch = async function (...args: Parameters<typeof globalThis["fetch"]>) {
        return globalThis.fetch(...args);
    };
    get = get;
    set = set;
    entries = entries;
    delete = _delete;
    has = has;
    setBaseUrl(url: string) {
        this[BASE_URL] = url;
    }
}
export { SystemJSCore, REGISTRY } from "./system-core";
export * from "./common";
